#!/usr/bin/env python
import wget
import sys

__version__ = "3.2"

if __name__ == "__main__":
    if len(sys.argv) < 2 or "-h" in sys.argv or "--help" in sys.argv:
        sys.exit(wget.usage)
    if "--version" in sys.argv:
        sys.exit("wget.py " + __version__)

    # patch Python 2.x to read unicode from command line
    if not wget.PY3K and sys.platform == "win32":
        sys.argv = wget.win32_utf8_argv()
    # patch Python to write unicode characters to console
    if sys.platform == "win32":
        wget.win32_unicode_console()

    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("-o", "--output", dest="output")
    (options, args) = parser.parse_args()

    url = sys.argv[1]
    filename = wget.download(args[0], out=options.output)

    print("")
    print("Saved under %s" % filename)
